/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.modudf;

import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JWindow;

public class MyPopupMenu extends PopupMenu{
    private JFrame j;
    private MenuItem m1;
    private MenuItem m2;
    
    public MyPopupMenu(JFrame j) {
        this.j = j;
        m1 = new MenuItem("显示界面");
        m2 = new MenuItem("退出");
        add(m1);
        add(m2);
        
        m1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MyPopupMenu.this.j.setVisible(true);
            }
        });
        
        m2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
    }
}
